package com.nnfe.fyd.feature.splash;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Window;
import android.widget.Button;

import com.nnfe.fyd.R;
import com.nnfe.fyd.ShareKey;
import com.nnfe.fyd.base.BaseActivity;
import com.nnfe.fyd.feature.login.LoginActivity;
import com.nnfe.fyd.feature.main.MainActivity;
import com.nnfe.fyd.utils.LogUtil;
import com.nnfe.fyd.utils.SharePrefUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * ----------------------------------
 * Created by xyd on 2017/3/27.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class SplashActivity extends BaseActivity {


    public static void launch(Activity context) {
        Intent intent = new Intent(context, SplashActivity.class);
        context.startActivity(intent);
    }


    @Bind(R.id.btn_next)
    Button btnNext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);
//        LogUtil.e("xyd", "是否是第一次启动：" + SharePrefUtil.getBooleanWithoutUser(mContext, ShareKey.isFirstStart, false));


        if (!SharePrefUtil.getBooleanWithoutUser(mContext, ShareKey.isFirstStart, true)) {
            MainActivity.launch(mContext);
            mContext.finish();
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    @Override
    public Fragment getContentFragment() {
        return null;
    }

    @OnClick(R.id.btn_next)
    public void onClick() {
        MainActivity.launch(mContext);
        SharePrefUtil.saveBooleanWithoutUser(mContext, ShareKey.isFirstStart, false);
        LoginActivity.lauch(mContext, LoginActivity.TYPE_LOGIN);
        mContext.finish();
    }
}
